import { BaseMessage } from '@langchain/core/messages';
import { Annotation, END } from '@langchain/langgraph';

export const BaseMessagesState = Annotation.Root({
  messages: Annotation<BaseMessage[]>({
    reducer: (x, y) => x.concat(y),
    default: () => [],
  }),
  next: Annotation<string>({
    reducer: (x, y) => y ?? x ?? END,
    default: () => END,
  }),
});
